package com.ejd.web.vo.customer;

import java.io.IOException;

import java.util.ArrayList;




import java.util.List;
import java.util.Locale;


import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

import net.sf.cglib.beans.BeanCopier;

import com.ejd.service.ICustomerService;
import com.ejd.service.impl.CustomerService;
import com.ejd.utils.DESPlusUtil;
import com.ejd.utils.EncryptUtils;
import com.ejd.utils.MessageFactory;
import com.ejd.utils.SpringFacesUtil;
import com.ejd.web.bo.impl.Customer;
import com.ejd.web.constant.EjdConstants;
import com.ejd.web.constant.ManageBeanConstants;
import com.ejd.web.constant.SpringBeanConstants;
import com.ejd.web.vo.common.CustomerVo;
import com.ejd.web.vo.genl.GenerateVerifyCodeBean;

@ManagedBean(name="customerRegisterSuccessPage")
@ViewScoped
public class CustomerRegisterSuccessPageBean implements java.io.Serializable {
	private static final long serialVersionUID = -8106629465344224783L;
	
	private String customerId;
	private String password;
	

	public String getCustomerId() {
		return customerId;
	}
	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}
	
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public CustomerRegisterSuccessPageBean() throws IOException{
		String customerId = (String) SpringFacesUtil.getRequestParameter("customerId");
		String param = (String) SpringFacesUtil.getRequestParameter("param");
		ICustomerService<Customer,Long> customerService = (ICustomerService<Customer,Long>) SpringFacesUtil.getSpringBean(SpringBeanConstants.CUSTOMER_SERVICE_BEAN_NAME);
		customerService.setEntityClass(Customer.class);
		customerService.setPKClass(Long.class);
		Customer customer = null;
		if (null != customerId && !("".equals(customerId))) {
			customer = customerService.findUniqueBy("customerId", customerId);
		}
		//not from create page
		if ((null == customerId) || ("".equals(customerId)) || (null == customer) || (!(customer.getPassword().equals(param)))) {
			SpringFacesUtil.redirectPage(EjdConstants.GO_TO_CUSTOMER_REGISTER_XTHML);
		} else {
			this.setCustomerId(customerId);
			this.setPassword(param);
		}
		
	}
}
